'use strict';

const db = uniCloud.database();
exports.main = async (event, context) => {
	const { id, fileList } = event; // 获取文件列表
    try {
		//先删除表数据
		const removeRes = await db.collection("word-bank").doc(id).remove()
		//在删除云存储
        const res = await uniCloud.deleteFile({
            fileList: fileList // 文件ID数组
        });
        return {
            code: 0,
            message: '文件删除成功',
            data: res
        };
    } catch (error) {
        return {
            code: 1,
            message: '文件删除失败',
            error: error.message
        };
    }
};
